package com.lm.calcite.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;

import java.sql.*;
import java.util.Properties;

@Configuration
public class CalciteConfig {

    @Bean
    public Connection calciteConnection() throws Exception {
        Properties props = new Properties();
        props.setProperty("lex", "MYSQL"); // SQL 风格
        // 通过类路径读取 model.json
        String modelPath = new ClassPathResource("model.json").getFile().getAbsolutePath();
        props.setProperty("model", modelPath);
        return DriverManager.getConnection("jdbc:calcite:", props);
    }
}
